<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" %>
    
<%@ page import="java.util.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login</title>
</head>
<body>

<%-- check if session attribute was initiated --%>
<%  if(session.getAttribute("loginCorrect") != null) { %>
	
	<%-- check if login was correct --%>
	<% 	if (((Boolean)session.getAttribute("loginCorrect") == true)) { %>

	<h1><a href="Login?name=Ich">Login</a></h1><br /><br />
		<b>GET: </b>
		<form action="Login" method="GET">
			<input name="name" type="text" size="30" maxlength="30" />
			<input name="submit" type="submit" />
		</form>

	<h2>System info: </h2>
	<ul>
	  <li>Current time: <%= new java.util.Date() %></li>
	  <li>Server: <%= application.getServerInfo() %></li>
	</ul>
	
	<h2>Information on Your Session: </h2>
	<table border="1">
       <tr>
         <th>Info Type<th>Value
       <tr>
         <td>ID</td>
         <td><%= session.getId() %></td>
       <tr>
         <td>Creation Time</td>
         <td><%= new Date(session.getCreationTime()) %></td>
       </tr>
       <tr>
         <td>Time of Last Access</td>
         <td><%= new Date(session.getLastAccessedTime()) %></td>
       </tr>
       <tr>
         <td>Number of Requests</td>
         <td><%= session.getAttribute("accessCount") %></td>
       </tr>
    </table>
	
	<%-- login was not correct --%>
	<% } else { %>
	
	<h2>Wrong username or password</h2>
	
<% } } %>

<%-- show login form except when loginCorrect == true --%>
<%  if(session.getAttribute("loginCorrect") == null || 
		((Boolean)session.getAttribute("loginCorrect") == false)) { %>
		
	<h1>Bitte einloggen:</h1>
	<form action = "Login" method = "post">
	<table>
	<tr>
		<td>Benutzername :</td>
		<td><input type = "text" name = "username"></td>
	</tr>
	<tr>
		<td>Passwort :</td>
		<td><input type = "password" name = "password"></td>
	</tr>
	<tr>
		<td><input type = "submit" value = "einloggen" name = "submit"></td>
	</tr>
	</table>
	</form>
<% } %>
// ein %> zuviel?
// Kommentarcheck Peter
</body>
</html>